package hadoop.mr05;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class PhoneMapper extends Mapper<LongWritable, Text,Phone,Text> {
    Text v2 = new Text();
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Phone, Text>.Context context) throws IOException, InterruptedException {
        String[] split = value.toString().split(",");
        long phone = Long.parseLong(split[1]); // 电话号码
        String state = split[2]; // 省份
        String county = split[3]; // 市
        String kind = split[4]; // 号码类别
        Phone k2 = new Phone(state,county,phone);
        v2.set(kind);
        context.write(k2,v2);
    }
}
